import type { RouteItem } from '../types'

export const basicRoutes: Array<RouteItem> = [
  {
    name: '404',
    path: '/404',
    component: () => import('@/views/error-page/404.vue'),
    isHidden: true,
    children: []
  },
  {
    name: 'Login',
    path: '/login',
    component: () => import('@/views/login/index.vue'),
    isHidden: true,
    meta: {
      title: 'app.menu.login'
    },
    children: []
  }
]

export const NOT_FOUND_ROUTE: RouteItem = {
  name: 'NotFound',
  path: '/:pathMatch(.*)*',
  redirect: '/404',
  isHidden: true,
  children: []
}

export const EMPTY_ROUTE: RouteItem = {
  name: 'Empty',
  path: '/:pathMatch(.*)*',
  component: null,
  children: []
}

const modules: TRecord<any> = import.meta.glob('@/views/**/route.ts', { eager: true })

const asyncRoutes: Array<RouteItem> = []

for (const key in modules) {
  if (Object.prototype.hasOwnProperty.call(modules, key)) {
    asyncRoutes.push(modules[key].default)
  }
}

export { asyncRoutes }
